using System;
using System.Collections.Generic;
using System.Linq;  // for ToList, ToArray ...
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;
using CoworkspaceAdmin.Models;

namespace CoworkspaceAdmin.Controller
{
    interface IProjectManager{
        Project GetProject(string id);
        void RemoveProject(string id);
        List<Project> GetAllProject();
    }

    public class ProjectManager : DbContext, IProjectManager
    {
        private readonly IConfiguration _config;
        Dictionary<string, Project> projects = new Dictionary<string, Project>();
        public ProjectManager()
        {
        }

        public Project GetProject(string id) {
            if (projects.ContainsKey(id)){
                return projects[id];
            }
            return null;
        }

        public void RemoveProject(string id) {
            if(projects.ContainsKey(id)){
                projects.Remove(id);
            }
        }

        public List<Project> GetAllProject() {
            return projects.Values.ToList();
        }
    }
}
